package com.gitee.ly;

import org.noear.nami.annotation.NamiClient;
import org.noear.nami.common.ContentTypes;
import org.noear.solon.annotation.*;

import java.net.InetAddress;
import java.net.UnknownHostException;

@Controller
public class TestController {
    @Inject("${server.port}")
    int appPort;

    //直接指定地址和序列化方案
//    @NamiClient(url = "http://localhost:8082/rpc", headers = ContentTypes.JSON)
    @NamiClient(name = "solon-main", headers = ContentTypes.JSON, path = "rpc")
    TestRpcService1 testRpcService;

    @Get
    @Mapping("getStr")
    public String getStr() throws UnknownHostException {
        String ip = InetAddress.getLocalHost().getHostAddress();
        String s = "solon-main1   " + ip + ":" + appPort;

        return s + " remote return: " + testRpcService.getStrOnce();
    }
}
